#include "main_ui.h"
#include "ui_cpu.h"
#include "ui_home.h"
#include "semphr.h"

void (*pMenucb)(void);
menu_t menu = MENU_HOME;
lv_obj_t* cont = NULL;


void uiTask(void* args)
{
    static u8 last_menu = MENU_INVALID;

    while (1)
    {
        if (xSemaphoreTake(xMutex, portMAX_DELAY) == pdTRUE) {
            if (last_menu != menu) {
                switch (menu)
                {
                case MENU_HOME:
                    home_show();
                    break;
                case MENU_CPU:
                    cpu_show();
                    break;
                    // case MENU_DATA:
                    //     lvgl_serial_assistant();
                    //     break;
                default:
                    break;
                }
                last_menu = menu;
            }

            if (pMenucb != NULL) {
                pMenucb();
            }

            xSemaphoreGive(xMutex);
        }
        vTaskDelay(5);
    }
}
